/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.vetor.model.entity;

import java.io.Serializable;
import java.util.List;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Moises.Moura
 */
@Entity
@Table(name = "grade", catalog = "dbvetor", schema = "")
@NamedQueries({
    @NamedQuery(name = "Grade.findAll", query = "SELECT g FROM Grade g"),
    @NamedQuery(name = "Grade.findByCodigo", query = "SELECT g FROM Grade g WHERE g.gradePK.codigo = :codigo"),
    @NamedQuery(name = "Grade.findByHoraInicio", query = "SELECT g FROM Grade g WHERE g.horaInicio = :horaInicio"),
    @NamedQuery(name = "Grade.findByHoraFim", query = "SELECT g FROM Grade g WHERE g.horaFim = :horaFim"),
    @NamedQuery(name = "Grade.findByDataAula", query = "SELECT g FROM Grade g WHERE g.dataAula = :dataAula"),
    @NamedQuery(name = "Grade.findByAlunoPessoaCodigo", query = "SELECT g FROM Grade g WHERE g.gradePK.alunoPessoaCodigo = :alunoPessoaCodigo")})
public class Grade implements Serializable {
    
    /**
	 * 
	 */
	private static final long serialVersionUID = -8689887933655369032L;
	@EmbeddedId
    protected GradePK gradePK;
   
	@Column(name = "hora_inicio", length = 4)
    private String horaInicio;
    
	@Column(name = "hora_fim", length = 4)
    private String horaFim;
    
	@Column(name = "data_aula")
    @Temporal(TemporalType.DATE)
    private Date dataAula;
    
	@ManyToMany(mappedBy = "gradeList")
    private List<Disciplina> disciplinaList;
    
	@JoinColumn(name = "aluno_pessoa_codigo", referencedColumnName = "pessoa_codigo", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Aluno aluno;

    public Grade() {
    }

    public Grade(GradePK gradePK) {
        this.gradePK = gradePK;
    }

    public Grade(int codigo, int alunoPessoaCodigo) {
        this.gradePK = new GradePK(codigo, alunoPessoaCodigo);
    }

    public GradePK getGradePK() {
        return gradePK;
    }

    public void setGradePK(GradePK gradePK) {
        this.gradePK = gradePK;
    }

    public String getHoraInicio() {
        return horaInicio;
    }

    public void setHoraInicio(String horaInicio) {
        this.horaInicio = horaInicio;
    }

    public String getHoraFim() {
        return horaFim;
    }

    public void setHoraFim(String horaFim) {
        this.horaFim = horaFim;
    }

    public Date getDataAula() {
        return dataAula;
    }

    public void setDataAula(Date dataAula) {
        this.dataAula = dataAula;
    }

    public List<Disciplina> getDisciplinaList() {
        return disciplinaList;
    }

    public void setDisciplinaList(List<Disciplina> disciplinaList) {
        this.disciplinaList = disciplinaList;
    }

    public Aluno getAluno() {
        return aluno;
    }

    public void setAluno(Aluno aluno) {
        this.aluno = aluno;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (gradePK != null ? gradePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Grade)) {
            return false;
        }
        Grade other = (Grade) object;
        if ((this.gradePK == null && other.gradePK != null) || (this.gradePK != null && !this.gradePK.equals(other.gradePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidadesvetor.Grade[gradePK=" + gradePK + "]";
    }

}
